home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Netrunner 2004 October
/
NETRUNNER0410.ISO
/
regular
/
sleipnir165.exe
/
{app}
/
developers
/
ExPanel
/
Generic
/
TabList.c
< prev
Wrap
C/C++ Source or Header
|
2004-06-27
|
8KB
|
334 lines
/*-----------------------------------------------------------------------------
* Sleipnir Sample Extended Panel Plugin
* Copyright (C) 2004 by Yasuyuki Kashiwagi. All Rights Reserved.
*
* Version 1.1
*
* âTâôâvâïègÆúâpâlâïâvâëâOâCâôé┼é╖üB
*
* é▒é╠â\ü[âXé╠ëⁿò╧üEözòzé═Ä⌐ùRé╔ìsé┴é─é¡é╛é│éóüB
-----------------------------------------------------------------------------*/
#include <windows.h>
#include "../SPlugin.h"
#ifdef __cplusplus
#define DLLExport extern "C" __declspec (dllexport)
#else
#define DLLExport __declspec (dllexport)
#endif
/*---------------------------------------------------------------------------*/
/* âOâìü[âoâïò╧Éö */
/*---------------------------------------------------------------------------*/
HINSTANCE g_hInstance = NULL;
HWND g_hWnd = NULL;
HWND g_hChildWnd = NULL;
/*---------------------------------------------------------------------------*/
/* âGâôâgâèü[â|âCâôâg */
/*---------------------------------------------------------------------------*/
BOOL WINAPI DllMain
(
HINSTANCE hinstDLL,
DWORD fdwReason,
LPVOID lpvReserved
)
{
if (fdwReason == DLL_PROCESS_ATTACH)
{
g_hInstance = hinstDLL;
}
return TRUE;
}
/*---------------------------------------------------------------------------*/
/* âvâëâOâCâôÅεò±Äµô╛ */
/*---------------------------------------------------------------------------*/
DLLExport SPX_USHORT SPX_CALL SPX_GetPluginInfo()
{
return MAKEWORD(SPX_PLUGIN_EXTENDED_PANEL, SPX_EXTENDED_PANEL_VERSION);
}
/*---------------------------------------------------------------------------*/
/* WM_SIZE */
/*---------------------------------------------------------------------------*/
static void OnSize
(
int cx,
int cy
)
{
if (IsWindow(g_hChildWnd))
{
MoveWindow(g_hChildWnd, 0, 0, cx, cy, TRUE);
}
}
/*---------------------------------------------------------------------------*/
/* WM_COMMAND */
/*---------------------------------------------------------------------------*/
static void OnCommand
(
HWND hWndCtrl,
WORD wNotify,
WORD wId
)
{
if (wNotify == LBN_DBLCLK)
{
MessageBox
(
g_hWnd,
"The item was selected.",
"Notify",
MB_OK|MB_ICONINFORMATION
);
}
}
/*---------------------------------------------------------------------------*/
/* ÉeâEâBâôâhâEâRü[âïâoâbâNè╓Éö */
/*---------------------------------------------------------------------------*/
static LRESULT CALLBACK WndCallbackProc
(
HWND hWnd,
UINT unMsg,
WPARAM wParam,
LPARAM lParam
)
{
/* âèâXâgâ{âbâNâXé╠Æ╩ÆmâüâbâZü[âWé≡é▒é▒é┼Åêù¥é╡é─é¡é╛é│éó */
switch (unMsg) {
case WM_SIZE:
OnSize(lParam & 0xFFFF, (lParam >> 16) & 0xFFFF);
break;
case WM_COMMAND:
OnCommand((HWND)lParam, (wParam >> 16) & 0xFFFF, wParam & 0xFFFF);
break;
}
return DefWindowProc(hWnd, unMsg, wParam, lParam);
}
/*---------------------------------------------------------------------------*/
/* SPX_Create */
/*---------------------------------------------------------------------------*/
static SPX_HWND SPX_CALL SPX_CreateProc
(
SPX_ISleipnir* ipSleipnir,
SPX_HWND hWndParent
)
{
WNDCLASS tThisClass;
const char szClassName[] = "Extended Panel Plugin Sample";
tThisClass.style = CS_HREDRAW | CS_VREDRAW;
tThisClass.lpfnWndProc = WndCallbackProc;
tThisClass.cbClsExtra = 0;
tThisClass.cbWndExtra = 0;
tThisClass.hInstance = g_hInstance;
tThisClass.hIcon = NULL;
tThisClass.hCursor = LoadCursor(NULL, IDC_ARROW);
tThisClass.hbrBackground = GetStockObject(WHITE_BRUSH);
tThisClass.lpszMenuName = NULL;
tThisClass.lpszClassName = szClassName;
RegisterClass(&tThisClass);
// if (!RegisterClass(&tThisClass))
// return NULL;
/* ÉeâEâBâôâhâEé≡ì∞ɼé╖éΘ */
g_hWnd = CreateWindow
(
szClassName,
"",
WS_CHILD|WS_VISIBLE,
0,
0,
200,
200,
hWndParent,
NULL,
g_hInstance,
NULL
);
if (g_hWnd == NULL)
return NULL;
/* ÄqâEâBâôâhâEé≡ì∞ɼé╖éΘ */
g_hChildWnd = CreateWindow
(
"LISTBOX",
"",
WS_CHILD|WS_VISIBLE|WS_VSCROLL|LBS_NOTIFY|LBS_NOINTEGRALHEIGHT,
0,
0,
200,
200,
g_hWnd,
NULL,
g_hInstance,
0
);
if (g_hChildWnd == NULL)
{
DestroyWindow(g_hWnd);
return NULL;
}
/* âtâHâôâgé≡èäéΦôûé─éΘ */
SendMessage
(
g_hChildWnd,
WM_SETFONT,
(WPARAM)GetStockObject(DEFAULT_GUI_FONT),
(LPARAM)FALSE
);
/* ÉeâEâBâôâhâEé≡ò╘é╖ */
return g_hWnd;
}
/*---------------------------------------------------------------------------*/
/* SPX_Destroy */
/*---------------------------------------------------------------------------*/
static SPX_LONG SPX_CALL SPX_DestroyProc
(
SPX_ISleipnir* ipSleipnir,
SPX_HWND hWnd
)
{
DestroyWindow(g_hChildWnd);
DestroyWindow(g_hWnd);
return SPX_ERR_CODE_SUCCESS;
}
/*---------------------------------------------------------------------------*/
/* SPX_Idle */
/*---------------------------------------------------------------------------*/
static SPX_LONG SPX_CALL SPX_IdleProc
(
SPX_ISleipnir* ipSleipnir,
SPX_HWND hWnd
)
{
if (IsWindow(g_hChildWnd))
{
int i;
SPX_ULONG qCount;
SPX_CHAR* caTitle;
SendMessage(g_hChildWnd, LB_RESETCONTENT, (WPARAM)0, (LPARAM)0);
if (ipSleipnir->SendMessage(SPX_SM_GETPAGECOUNT, (SPX_ULONG)&qCount, 0) == SPX_ERR_CODE_SUCCESS)
{
for (i=0; i<qCount; i++)
{
if (ipSleipnir->SendMessage(SPX_SM_GETTITLE, (SPX_ULONG)i, (SPX_ULONG)&caTitle) == SPX_ERR_CODE_SUCCESS)
{
SendMessage(g_hChildWnd, LB_ADDSTRING, (WPARAM)0, (LPARAM)caTitle);
ipSleipnir->Free(caTitle);
}
}
}
}
return SPX_ERR_CODE_SUCCESS;
}
/*---------------------------------------------------------------------------*/
/* SPX_Property */
/*---------------------------------------------------------------------------*/
static SPX_LONG SPX_CALL SPX_PropertyProc
(
SPX_ISleipnir* ipSleipnir,
SPX_HWND hWnd,
SPX_ULONG x,
SPX_ULONG y
)
{
MessageBox
(
hWnd,
"TabList\n\n"
"Copyright (C) 2004 by Yasuyuki Kashiwagi\n"
"All Rights Reserved.",
"TabList Plugin",
MB_OK|MB_ICONINFORMATION
);
return SPX_ERR_CODE_SUCCESS;
}
/*---------------------------------------------------------------------------*/
/* âvâëâOâCâôÅëè·ë╗ */
/*---------------------------------------------------------------------------*/
DLLExport SPX_LONG SPX_CALL SPX_Initialize
(
SPX_IBrowserEventListener* ipEvent
)
{
ipEvent->OnCreate = SPX_CreateProc;
ipEvent->OnDestroy = SPX_DestroyProc;
ipEvent->OnIdle = SPX_IdleProc;
ipEvent->OnProperty = SPX_PropertyProc;
return SPX_ERR_CODE_SUCCESS;
}
/*---------------------------------------------------------------------------*/
/* Visual C++ ùp âGâNâXâ|ü[âgû╝é╠ò╧è╖ */
/*---------------------------------------------------------------------------*/
#ifdef _MSC_VER
#pragma comment(linker, "/EXPORT:SPX_GetPluginInfo=_SPX_GetPluginInfo@0")
#pragma comment(linker, "/EXPORT:SPX_Initialize=_SPX_Initialize@4")
#endif